package com.weaver.seconddev.tl.reghook;

import com.weaver.common.distribution.genid.IdGenerator;
import com.weaver.verupgrade.conn.RecordSet;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author chenkang.xu@weaver.cn
 * @create 2025-09-07 上午11:25
 * @Description
 */
@Slf4j
public class DocShareUtil {

    /**
     * 给文档添加一个用户可编辑权限
     * @param rs
     * @param docid
     * @param userid
     */
    public static  void addUserShare(RecordSet rs,Long docid,Long userid){
        String sql="INSERT INTO e10_core_business.document_ph_doc_s01 (" +
        //String sql="INSERT INTO ecology10.document_ph_doc_s01 (" +
                "  id," +
                "  module_id," +
                "  source_type," +
                "  source_id," +
                "  source_sub_id," +
                "  source_create_time," +
                "  source_min_sec_level," +
                "  source_max_sec_level," +
                "  source_station_level," +
                "  source_role_level," +
                "  source_organization_dimension," +
                "  target_type," +
                "  target_id," +
                "  target_sub_id," +
                "  target_min_sec_level," +
                "  target_max_sec_level," +
                "  target_station_level," +
                "  target_station_bs_id," +
                "  target_role_level," +
                "  target_organization_dimension," +
                "  target_subordinate_include," +
                "  permission_type," +
                "  tenant_key," +
                "  create_time," +
                "  update_time," +
                "  creator," +
                "  delete_type," +
                "  permission_config_id," +
                "  source_origin_id," +
                "  permission_config_source_id," +
                "  download," +
                "  permission_external_id," +
                "  permission_source_creator_id" +
                ")" +
                "VALUES" +
                "(" +
                "  ?," +
                "  NULL," +
                "  1," +
                "  ?," +
                "  NULL," +
                "  NULL," +
                "  0," +
                "  9999," +
                "  NULL," +
                "  NULL," +
                "  NULL," +
                "  1," +
                "  ?," +
                "  NULL," +
                "  10," +
                "  255," +
                "  NULL," +
                "  NULL," +
                "  0," +
                "  NULL," +
                "  NULL," +
                "  ?," +
                "  ?," +
                "  ?," +
                "  ?," +
                "  ?," +
                "  0," +
                "  NULL," +
                "  NULL," +
                "  NULL," +
                "  1," +
                "  NULL," +
                "  NULL" +
                ")";
        Date date = new Date(System.currentTimeMillis());// 获得当前的时间戳
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 定义格式
        String nowTime = dateFormat.format(date);// 格式化时间
        long generateID = IdGenerator.generate();
        log.error("generateID:"+generateID);
        rs.executeForWf(sql, generateID,docid,userid,"7","tl2k2r96ty",nowTime,nowTime,userid);
    }
}
